package com.kkb.service.dianpugaikuang.impl;

import com.kkb.bean.BillTable;
import com.kkb.bean.JbShopinfo;
import com.kkb.dao.BillTableMapper;
import com.kkb.dao.JbShopinfoMapper;
import com.kkb.dao.OrderTableMapper;
import com.kkb.service.dianpugaikuang.DianPuGaiKuangServcie;
import com.kkb.utils.util.DateUtils;
import com.kkb.vo.BaseResp;
import com.kkb.vo.dianpugaikuang.SelectBillSReq;
import com.kkb.vo.dianpugaikuang.SelectDainPuGuanZhu;
import com.kkb.vo.dianpugaikuang.SelectOrderSReq;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author sufenglong
 * @date 2021/4/13 11:23
 * @describe:
 */
@Service
public class DianPuGaiKuangServiceImpl implements DianPuGaiKuangServcie {


    @Resource
    private JbShopinfoMapper jbShopinfoMapper;

    @Resource
    private OrderTableMapper orderTableMapper;

    @Resource
    private BillTableMapper billTableMapper;


    /**
     * 店铺关注数
     *
     * @param selectDainPuGuanZhu
     * @return
     */
    @Override
    public Map<String, Object> selectGuanZhuBySid(SelectDainPuGuanZhu selectDainPuGuanZhu) {

        Map map = new HashMap();
        JbShopinfo jbShopinfo = new JbShopinfo();
        jbShopinfo.setsId(selectDainPuGuanZhu.getSId());
        List<JbShopinfo> select = jbShopinfoMapper.select(jbShopinfo);
        map.put("select",select);
        return map;
    }


    /**
     * 今(昨)日订单量
     *
     * @param selectOrderSReq
     * @return
     */
    @Override
    public Map<String, Object> selectJOrder(SelectOrderSReq selectOrderSReq) {

        Map<String, Object> map = new HashMap<>();
        //今日订单量
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String format = dateFormat.format(date);
        selectOrderSReq.setOrderTime(format);
        Integer integer = orderTableMapper.selectJOrder(selectOrderSReq);
        map.put("jinri", integer);

        //昨日订单量
        String yesterday = DateUtils.yesterday();
        selectOrderSReq.setOrderTime(yesterday);
        Integer integer1 = orderTableMapper.selectJOrder(selectOrderSReq);
        map.put("zuori", integer1);
        return map;
    }

    /**
     * 今(昨)日收入
     *
     * @param selectBillSReq
     * @return
     */
    @GetMapping("/selectJIncome")
    @Override
    public Map<String, Object> selectJIncome(SelectBillSReq selectBillSReq) {

        Map<String, Object> map = new HashMap<>();
        //今日收入
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String format = dateFormat.format(date);
        selectBillSReq.setBillTime(format);
        Integer integer = billTableMapper.selectJIncome(selectBillSReq);
        map.put("jinri", integer);

        //昨日收入
        String yesterday = DateUtils.yesterday();
        selectBillSReq.setBillTime(yesterday);
        Integer integer1 = billTableMapper.selectJIncome(selectBillSReq);
        map.put("zuori", integer1);
        return map;



    }


}
